// JavaScript Document

/*
	Voodoo Validator
	www.voodoovalidator.com
*/

/*
	For help: admin@voodoovalidator.com
*/

/*
	This application was developed originally by 
	Robbie Vasquez - www.robbievasquez.com
	Casey McLaughlin - www.caseymclaughlin.com
*/

/*
	BIRTHDAY: June 1st, 2009
	LAST MODIFIED: 08/12/2010
	BY: Robbie Vasquez
*/

<!---------------------------------------------------->

/*
	This script acts only when the voodoovalidator.php page is loaded.
	It gathers information from the <h3> elements on the page
	and runs it through the script on validate_continue.php
	to print both the validation of files in the root and
	open directories in the root when they are clicked.
	
	The voodoovalidator.php must have jQuery
	This is running with jQuery version 1.4
*/

$(document).ready(function() {
	
	// 'the_url' is the address of the website you are validating.
	// It is used for the validation script in validate_w3c_v4.php
	// Include trailing slash!!!
	var the_url = 'http://www.example.com/';
	
	// Each one of the directories in the root folder is of class 'directory'
	// The class can be changed, but this script and the class of the <h3>
	// elements on voodoovalidator.php must match the class specified here.
	$('h3.directory').click(function() {
		// 'dir' is needed to open the directories that sit in the root
		// validate_continue.php uses that as a $_GET variable to do so.
		var dir = $(this).attr('id')
		
		if($(this).attr('class') == 'directory')
		{
			$(this).removeClass('directory').addClass('clicked');
			// Each <li> element on voodoovalidator.php has a class matching
			// the name of the directory it will hold when the <h3> element
			// within it is clicked
			$('li.' + dir).load('/voodoo_scripts/validate_continue.php', 'dir=' + dir);
		}
	});
	
	// In voodoovalidator.php there is a set of <li> elements, all with a class 'file'
	// Those <li> elements hold the name of the file as 'id' values.
	// Any <li> element of class 'file' provides information to be used by the
	// validating file, validate_w3c_v4.php
	$.each($('li.file'), function() {
											
		// 'the_file_name' is the full path to the file from the root to the file itself
		var the_file_name = the_url + $(this).attr('id');
		
		// 'name' is only used for display purposes
		var name = $(this).attr('id');
		
		// This changes the class from 'file' to 'checked' so it will be validated only once
		// but will be set up to validate individually again when clicked.
		// That ability is set up in validate_w3c_v4.php and validate_refresh.php
		$(this).removeClass('file').addClass('checked');
		
		// Prints the results which are echo'd in validate_w3c_v4.php
		$(this).load('/voodoo_scripts/validate_w3c_v4.php', 'url=' + the_file_name + '&file=' + name);
	});

});